package com.example.demo.dao;

import com.example.demo.entity.CircleLike;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface CircleLikeDao extends JpaRepository<CircleLike,Integer> {

    // 根据用户ID和圈子ID来查询
    List<CircleLike> findByUserIdAndCircleId(int userId,int circleId);

    // 取消点赞【相同名称只取消一个】
    @Query(value = "select nickname from user where id in ( select userId from circle_like where circleId = ?1 and status = 1)",nativeQuery = true)
    List<String> getListUser(int circleId);

    // 查询自己点赞过的圈子
    @Query(value = "select count(circleId) from circle_like where userId=?1 and status = 1",nativeQuery = true)
    int getLikeCount(int userId);



}
